package plenprojects.guiclient.frames;

import java.awt.CardLayout;
import java.awt.Dimension;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.UIManager;


public class MainFrame extends javax.swing.JFrame {
    
    private CardLayout layout = new CardLayout();
    
    public MainFrame() {
        
        initComponents();
        MenuBar.setVisible(false);//the same as popup menu
        MenuBar.removeAll();
        
        JMenu menu = new JMenu("Menu");
        
        MenuBar.add(menu);
        
        menu.add(new JMenuItem("Logout"));
    }
    
    public void switchTo(String id) {
        
        layout.show(ContentPanel, id);
        
        if(id.equals("main")) {
            
            Dimension dim = this.getSize();
            this.setSize(new Dimension(dim.width, dim.height + MenuBar.getHeight()));
            MenuBar.setVisible(true);
        }
    }
                         
    private void initComponents() {

        ContentPanel = new javax.swing.JPanel();
        MenuBar = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ChatSwingClient");
        setResizable(false);

        javax.swing.GroupLayout ContentPanelLayout = new javax.swing.GroupLayout(ContentPanel);
        ContentPanel.setLayout(ContentPanelLayout);
        ContentPanelLayout.setHorizontalGroup(
            ContentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 563, Short.MAX_VALUE)
        );
        ContentPanelLayout.setVerticalGroup(
            ContentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 294, Short.MAX_VALUE)
        );

        jMenu3.setText("File");
        MenuBar.add(jMenu3);

        jMenu4.setText("Edit");
        MenuBar.add(jMenu4);

        setJMenuBar(MenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }
    
    private javax.swing.JPanel ContentPanel;
    private javax.swing.JMenuBar MenuBar;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;               
}
